import React from 'react'

import { Form, Icon, Input, Button, Checkbox } from 'antd';




class NormalLoginForm extends React.Component {
  constructor(props){
    super(props)
  }
  componentDidMount(){
    console.log(this)
    window.$axios.post("/api/shopList2").then(res => {
      console.log(res)
    })
  }
  handleSubmit = e => {
    e.preventDefault();
    this.props.form.validateFields((err, values) => {
      if (!err) {
        console.log('Received values of form: ', values);
        this.props.history.push('/')
      }
    });
  };

  render() {
    const { getFieldDecorator } = this.props.form;
    return (
        <div className="login-wrap">

      <Form onSubmit={this.handleSubmit} className="login-form" style={{width:300,margin:'0 auto'}}>
          <div className="login-header">
            <div className="logo login-logo"></div>
            <h1>Ant Design</h1>
          </div>
        <Form.Item>
          {getFieldDecorator('username', {
            rules: [{ required: true, message: 'Please input your username!' }],
          })(
            <Input
              prefix={<Icon type="user" style={{ color: 'rgba(0,0,0,.25)' }} />}
              placeholder="Username"
            />,
          )}
        </Form.Item>
        <Form.Item>
          {getFieldDecorator('password', {
            rules: [{ required: true, message: 'Please input your Password!' }],
          })(
            <Input
              prefix={<Icon type="lock" style={{ color: 'rgba(0,0,0,.25)' }} />}
              type="password"
              placeholder="Password"
            />,
          )}
        </Form.Item>
        <Form.Item>
          {getFieldDecorator('remember', {
            valuePropName: 'checked',
            initialValue: true,
          })(<Checkbox>自动登录</Checkbox>)}
          <a className="login-form-forgot fr" href="">
            忘记密码?
          </a>
          <div>
          <Button type="primary" htmlType="submit" className="login-form-button" >
            登录
          </Button>
          </div>
          <span className="color-gray">没账号，去</span> <a href="">注册</a>
        </Form.Item>
      </Form>
      </div>
    );
  }
}

const WrappedNormalLoginForm = Form.create({ name: 'normal_login' })(NormalLoginForm);

export default WrappedNormalLoginForm;